import java.io.Serializable;
import java.util.Date;
import java.util.List;

public class Order implements Serializable {
    private Integer id;
    private Integer userId;
    private List<OrderItem> items;
    private Double totalAmount;
    private Date createTime;
    private String status;

    public Order() {}

    public Order(Integer id, Integer userId, List<OrderItem> items, Double totalAmount, Date createTime, String status) {
        this.id = id;
        this.userId = userId;
        this.items = items;
        this.totalAmount = totalAmount;
        this.createTime = createTime;
        this.status = status;
    }

    public Integer getId() { return id; }
    public void setId(Integer id) { this.id = id; }

    public Integer getUserId() { return userId; }
    public void setUserId(Integer userId) { this.userId = userId; }

    public List<OrderItem> getItems() { return items; }
    public void setItems(List<OrderItem> items) { this.items = items; }

    public Double getTotalAmount() { return totalAmount; }
    public void setTotalAmount(Double totalAmount) { this.totalAmount = totalAmount; }

    public Date getCreateTime() { return createTime; }
    public void setCreateTime(Date createTime) { this.createTime = createTime; }

    public String getStatus() { return status; }
    public void setStatus(String status) { this.status = status; }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append(String.format("订单ID: %d, 用户ID: %d, 总金额: %.2f, 状态: %s, 创建时间: %s\n",
                id, userId, totalAmount, status, createTime));
        sb.append("订单明细:\n");
        if (items != null) {
            for (OrderItem item : items) {
                sb.append("  ").append(item.toString()).append("\n");
            }
        }
        return sb.toString();
    }
}